#include "grflib_stdafx.h"
#include <DXUTgui.h>
#include "Dialog.h"

using namespace grflib::engine::aux;

//set appearance
void CDialog::SetDimension(int _w, int _h, int _x, int _y)
{
	width = _w; height = _h; 
	x = _x; y = _y;
}

void CDialog::ToggleVisibility(void)
{
	m_bVisible = !m_bVisible;
}

HRESULT CDialog::OnResize(ID3D10Device *pd3dDevice, IDXGISwapChain *pSwapChain, const DXGI_SURFACE_DESC *pBufferSurfaceDesc)
{
	m_dialog.SetSize(width, height);
	int xx = x >= 0 ? x : pBufferSurfaceDesc->Width + x;
	int yy = y >= 0 ? y : pBufferSurfaceDesc->Height + y;
	m_dialog.SetLocation(xx, yy);
	return S_OK;
}

bool CDialog::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ 
	if (m_bVisible) 
		return m_dialog.MsgProc(hWnd, uMsg, wParam, lParam); 
	return false; 
}

HRESULT CDialog::OnRender(ID3D10Device *pd3dDevice, const D3DXMATRIX *pWorldMat, double fTime, float fElapsedTime, UINT pass)
{ 
	if (m_bVisible) 
		return m_dialog.OnRender(fElapsedTime);
	else 
		return S_OK;
}
